package com.principle.singleresponsilbility;

/**
 * @author xuehu
 * @date 2020/12/4 10:53
 * 单一职责原则
 */
public class Singleresponsibility2 {

    public static void main(String[] args) {
        RoadVegicle roadVegicle = new RoadVegicle();
        roadVegicle.run("摩托车");
        roadVegicle.run("汽车");

        AirVegicle airVegicle = new AirVegicle();
        airVegicle.run("飞机");

    }

}

//方案2的分析
//1.遵守单一职责的原则
//2.但是这样做的改动很大,即将类分离,同时修改客户端
//3.改进:直接修改Vehicle类,改动的代码会比较少 =>方案3

class RoadVegicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在公路运行");
    }
}


class AirVegicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "在天空运行");
    }
}



